<script lang="ts" setup>
import BaseBtn from '@/components/BaseBtn.vue'
import Cookies from 'js-cookie'
import { tokenCookieKey } from '@/config'
import { useRoute, useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import { login } from '@/api/modules/user'

const route = useRoute()
const router = useRouter()
const userStore = useUserStore()

function loginHandler () {
  // login({
  //   userName: '222',
  //   password: '111'
  // })
  //   .then(res => {
  //     console.log(res.data)
  //   })
  //   .catch(err => {
  //     console.log(err)
  //   })
  Cookies.set(tokenCookieKey, '111')
  userStore.setToken('111')
  if (route.query.redirect && route.query.redirect !== 'login') {
    router.push({ name: route.query.redirect as string })
  } else {
    router.push({ name: 'home' })
  }
}
</script>

<template>
  <div>
    <h1>登录页</h1>
    <BaseBtn @click="loginHandler">登录</BaseBtn>
  </div>
</template>

<style scoped>

</style>
